package com.itheima.controller;

import com.itheima.entity.Emp;
import com.itheima.entity.LoginVo;
import com.itheima.entity.Result;
import com.itheima.service.EmpService;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description LoginController
 * @Author 你的名字拼接或昵称
 * @Date 2025-09-07
 */
@Slf4j
@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private EmpService empService;

    @PostMapping
    public Result login(@RequestBody Emp emp){
        LoginVo loginVo =empService.login(emp);
        if (loginVo ==null){
            return  Result.error("账号或密码错误");
        }
        return Result.success(loginVo);
    }
}
